package com.myt.matp.gui;


public final class UIScrollBar extends UIWidget {

    public static final int FLAG_VERTICAL = 0x00000001; 
    public static final int FLAG_HORIZONTAL = 0x00000002; // future

    private int m_Thick = 2;

    private int m_Frame = 0;
    private int m_Content = 0;
    private int m_Redisplay = 0;

    protected UIScrollBar(int id, GUI gui) {
	super(id, gui);
    }

    public final int getType() {
	return UIWidget.SCROLLBAR;
    }

    public void setThick(int thick) {
	m_Thick = (thick < 2) ? 2 : thick;
    }

    public void resized() {
    }

    public int getThick() {
	return m_Thick;
    }

    public void set(int content, int redisplay, int frame) {
	m_Content = content;
	m_Redisplay = redisplay;
	m_Frame = frame;
    }

    protected int getMinWidth() {
	return super.getMinWidth() + getThick();
    }

    protected int getMaxWidth() {
	return getMinHeight();
    }

    protected void paintUIWidget(MGraphics g) {
	if (hasProperties(PROP_VISIBLE)) {
	    if (m_Content > 0) {
		// Set Color
		//m_Gui.setColor(getColor(COLOR_FOREGROUND));
		g.setColor(0);
		// fill rect
		g.fillRect(getViewX(), 
			   getViewY() + getViewHeight() * m_Frame / m_Content,
			   getThick(), 
			   getViewHeight() * m_Redisplay / m_Content);
	    }
	}
    }
}